package com.zoe.app.config;

import cn.hutool.core.util.CharsetUtil;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Zoe.Zhang
 * @date 2021/09/25
 * @description
 */
@Configuration
public class DynamicFastJsonConfig {
    @Bean
    FastJsonHttpMessageConverter httpMessageConverter() {
        FastJsonHttpMessageConverter fastJsonHttpMessageConverter = new FastJsonHttpMessageConverter();
        FastJsonConfig fastJsonConfig = new FastJsonConfig();
        fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
        fastJsonHttpMessageConverter.setFastJsonConfig(fastJsonConfig);
        fastJsonHttpMessageConverter.setDefaultCharset(CharsetUtil.CHARSET_UTF_8);
        return fastJsonHttpMessageConverter;
    }
}
